package com.kate.mall.member.controller;

import java.util.Arrays;
import java.util.Map;

//import org.apache.shiro.authz.annotation.RequiresPermissions;
import com.kate.mall.common.utils.PageUtils;
import com.kate.mall.common.utils.R;
import com.kate.mall.member.entity.SearchHistoryEntity;
import com.kate.mall.member.service.SearchHistoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Api;


/**
 * 搜索历史表 
 *
 * @author kate-chan
 * @email ccsu_loader@163.com
 * @date 2021-10-08 16:10:48
 */
@Api(tags = "SearchHistoryController", description = "搜索历史表 服务")
@RestController
@RequestMapping("user/searchhistory")
public class SearchHistoryController {
    @Autowired
    private SearchHistoryService searchHistoryService;

    /**
     * 列表
     */
    @GetMapping("/list")
    //@RequiresPermissions("user:searchhistory:list")
    @ApiOperation("获取所有搜索历史表 信息")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = searchHistoryService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @GetMapping("/info/{id}")
    //@RequiresPermissions("user:searchhistory:info")
    @ApiOperation("获取指定id的搜索历史表 详情")
    public R info(@PathVariable("id") Integer id){
		SearchHistoryEntity searchHistory = searchHistoryService.getById(id);

        return R.ok().put("searchHistory", searchHistory);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    @ApiOperation("添加搜索历史表 信息")
    //@RequiresPermissions("user:searchhistory:save")
    public R save(@RequestBody SearchHistoryEntity searchHistory){
		searchHistoryService.save(searchHistory);

        return R.ok();
    }

    /**
     * 修改
     */
    @PutMapping("/update")
    @ApiOperation("更新指定id搜索历史表 信息")
    //@RequiresPermissions("user:searchhistory:update")
    public R update(@RequestBody SearchHistoryEntity searchHistory){
		searchHistoryService.updateById(searchHistory);

        return R.ok();
    }

    /**
     * 删除
     */
    @DeleteMapping("/delete")
    @ApiOperation("删除指定id搜索历史表 信息")
    //@RequiresPermissions("user:searchhistory:delete")
    public R delete(@RequestBody Integer[] ids){
		searchHistoryService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
